//* guided missile that move towards ship like follower but renders differently, is faster and have limited lifespan, it is produced by other aliens

function AlienMissile(ALeft,ATop) {
  // contructor
  var that = new Alien();
  that.images = null;
  that.color = 'rgba(255,0,0,1.0)';
  that.credit = 0;
  that.shrapnel = 3;
  that.x = ALeft;
  that.y = ATop;
  that.max_speed = 7;
  that.life = 10;
  that.size = 5;
  
  // update
  that.update = function() {
    // missile move towards ship
    this.angle = Math.atan2(ship.y-this.y,ship.x-this.x);
    this.dx = this.max_speed*(Math.cos(this.angle));
    this.dy = this.max_speed*(Math.sin(this.angle));
    // move
    this.x += this.dx;
    this.y += this.dy;
    // missiles short lived
    if (this.frame >= 50)
      this.life = 0;
  }
 
  return that;
}

function AlienMissiles(ACount,ALeft,ATop) {
  // create array of aliens
  var that = new Array();
  for (var i=0; i<ACount; i++)
      that.push(new AlienMissile(ALeft,ATop));
  return that;  
}
